/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.fh.itsbankomat.businesslogic.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MeinLaptop
 */
@Entity
@Table(name = "KREDITINSTITUT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Kreditinstitut.findAll", query = "SELECT k FROM Kreditinstitut k"),
    @NamedQuery(name = "Kreditinstitut.findByBic", query = "SELECT k FROM Kreditinstitut k WHERE k.bic = :bic"),
    @NamedQuery(name = "Kreditinstitut.findByName", query = "SELECT k FROM Kreditinstitut k WHERE k.name = :name"),
    @NamedQuery(name = "Kreditinstitut.findByPlz", query = "SELECT k FROM Kreditinstitut k WHERE k.plz = :plz"),
    @NamedQuery(name = "Kreditinstitut.findByOrt", query = "SELECT k FROM Kreditinstitut k WHERE k.ort = :ort"),
    @NamedQuery(name = "Kreditinstitut.findByStrasse", query = "SELECT k FROM Kreditinstitut k WHERE k.strasse = :strasse")})
public class Kreditinstitut implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 11)
    @Column(name = "BIC")
    private String bic;
    @Size(max = 50)
    @Column(name = "NAME")
    private String name;
    @Size(max = 5)
    @Column(name = "PLZ")
    private String plz;
    @Size(max = 30)
    @Column(name = "ORT")
    private String ort;
    @Size(max = 40)
    @Column(name = "STRASSE")
    private String strasse;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kreditinstitut")
    private Collection<Konto> kontoCollection;

    public Kreditinstitut() {
    }

    public Kreditinstitut(String bic) {
        this.bic = bic;
    }

    public String getBic() {
        return bic;
    }

    public void setBic(String bic) {
        this.bic = bic;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPlz() {
        return plz;
    }

    public void setPlz(String plz) {
        this.plz = plz;
    }

    public String getOrt() {
        return ort;
    }

    public void setOrt(String ort) {
        this.ort = ort;
    }

    public String getStrasse() {
        return strasse;
    }

    public void setStrasse(String strasse) {
        this.strasse = strasse;
    }

    @XmlTransient
    public Collection<Konto> getKontoCollection() {
        return kontoCollection;
    }

    public void setKontoCollection(Collection<Konto> kontoCollection) {
        this.kontoCollection = kontoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (bic != null ? bic.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Kreditinstitut)) {
            return false;
        }
        Kreditinstitut other = (Kreditinstitut) object;
        if ((this.bic == null && other.bic != null) || (this.bic != null && !this.bic.equals(other.bic))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.fh.itsbankomat.businesslogic.model.Kreditinstitut[ bic=" + bic + " ]";
    }
    
}
